<template>
  <div class="bg">
    <NewHomeHeader/>
    <div class="img_bg">
      <img class="bg" src="https://image.utea88.com/statics/pc_zixun_bg_01.png" alt="">
      <img class="title_img" src="https://image.utea88.com/statics/pc_zixun_item_01.png" alt="">
    </div>
    <div class="main_bg">
      <div class="main_section">
        <el-carousel :interval="5000" height="340px">
          <el-carousel-item v-for="(item, index) in newsList" :key="index">
            <div @click="handleClick(item)" class="carousel_section">
              <div class="img_bg">
                <img :src="item.image" alt="">
              </div>
              <div class="right_bg">
                <div class="time">{{ item.createTime }}</div>
                <div class="title">{{ item.name }}</div>
                <div class="line"></div>
                <div class="detail">{{ item.viceName }}</div>
                <div class="btn">查看详情 ></div>
              </div>
            </div>
          </el-carousel-item>
        </el-carousel>
        <div class="list_section">
          <div @click="handleClick(item)" class="item_bg" v-for="(item, index) in list" :key="index">
            <div class="item_section">
              <div class="img_bg">
                <img :src="item.image" alt="">
              </div>
              <div class="right_bg">
                <div class="title">{{ item.name }}</div>
                <div class="time">{{ item.createTime }}</div>
                <div class="detail">{{ item.viceName }}</div>
              </div>
            </div>
            <div class="line"></div>
          </div>
          <div class="bottom_line"></div>
        </div>
        <Pagination v-if="list.length > 0" :pageNo.sync="listQuery.pageNo" :pageSize.sync="listQuery.pageSize" :total="total" :autoScroll="false" 
          @change="getListData()" />
      </div>
    </div>
		<Footer></Footer>
  </div>
</template>

<script>
	import NewHomeHeader from "./components/NewHomeHeader.vue"
  import Footer from "@/views/front/components/Footer";
  import Pagination from "@/views/front/components/Pagination";
  import {
		getNewData
	} from "@/api/front-home.js";

	export default {
    name: 'ZiXun',
		components: {
			NewHomeHeader,
      Footer,
      Pagination
		},
		data() {
			return {
        newsList: [],
        list: [],
        listQuery: {
          pageNo: 1,
          pageSize: 10,
          code$in: 'news',
        },
        total: 0,
			}
		},
		methods: {
      handleClick(item) {
        this.$router.push({
          path: "/front-newDetail",
          query: {
            id: item.id
          },
        });
      },
			getTopData() {
				let data = {
					pageNo: 1,
					pageSize: 3,
					code$in: 'news',
				};
				getNewData(data).then((res) => {
					this.newsList = res.list;
				});
			},
      getListData() {
        getNewData(this.listQuery).then(res => {
          this.list = res.list || [];
          this.total = res.totalCount;
        });
      }
  	},
    mounted(){
             
    },
    created() {
      this.getTopData()
      this.getListData()
    },
	}
</script>

<style scoped lang="scss">
  .bg {
    position: relative;
    width: 100%;
    height: 100%;
  }

  .img_bg {
    position: relative;
    width: 100%;
    height: 600px;

    .bg {
      width: 100%;
      height: 100%;
    }

    .title_img {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 429px;
      height: 177px;
    }
  }

  .main_bg {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;

    .main_section {
      position: relative;
      margin-top: 60px;
      width: 1040px;
    }
  }

  .carousel_section {
    position: relative;
    width: 100%;
    height: 340px;
    cursor: pointer;

    .img_bg {
      position: absolute;
      top: 0;
      left: 0;
      width: 510px;
      height: 100%;

      img {
        width: 100%;
        height: 100%;
      }
    }

    .right_bg {
      position: absolute;
      top: 0;
      right: 0;
      padding: 25px 30px 0 30px;
      width: 530px;
      height: 100%;
      background: rgb(242, 242, 242);

      .time {
        height: 19px;
        opacity: 1;
        /** 文本1 */
        font-size: 14px;
        font-weight: 400;
        letter-spacing: 0px;
        line-height: 19px;
        color: rgba(102, 102, 102, 1);
        text-align: left;
        vertical-align: top;
      }

      .title {
        margin-top: 10px;
        width: 100%;
        height: 53px;
        opacity: 1;
        /** 文本1 */
        font-size: 20px;
        font-weight: 400;
        letter-spacing: 0px;
        line-height: 26.4px;
        color: rgba(0, 0, 0, 1);
        text-align: left;
        vertical-align: top;
        @include ellipsis($line: 2);
      }

      .line {
        margin-top: 20px;
        width: 100%;
        height: 1px;
        opacity: 1;
        background: rgba(221, 221, 221, 1);
      }

      .detail {
        margin-top: 16px;
        width: 100%;
        height: 90px;
        opacity: 1;
        /** 文本1 */
        font-size: 14px;
        font-weight: 400;
        letter-spacing: 0px;
        line-height: 30px;
        color: rgba(0, 0, 0, 1);
        text-align: left;
        vertical-align: top;
        @include ellipsis($line: 3);
      }

      .btn {
        margin-top: 50px;
        width: 100px;
        height: 36px;
        line-height: 36px;
        border-radius: 2px;
        text-align: center;
        background: rgba(255, 255, 255, 1);
        border: 1px solid rgba(204, 204, 204, 1);
      }
    }
  }

  .list_section {
    position: relative;
    margin-top: 90px;
    width: 100%;

    .bottom_line {
      position: absolute;
      left: 0px;
      bottom: 0;
      width: 100%;
      height: 1px;
      opacity: 1;
      background: rgba(218, 224, 232, 1);
    }

    .item_bg {
      position: relative;
      width: 100%;
      height: 220px;
      display: flex;
      align-items: center;
      cursor: pointer;

      .line {
        position: absolute;
        left: 0px;
        top: 0;
        width: 100%;
        height: 1px;
        opacity: 1;
        background: rgba(218, 224, 232, 1);
      }

      .item_section {
        position: relative;
        width: 100%;
        height: 160px;

        .img_bg {
          position: absolute;
          left: 0;
          top: 0;
          width: 240px;
          height: 160px;

          img {
            width: 100%;
            height: 100%;
          }
        }

        .right_bg {
          position: absolute;
          left: 260px;
          top: 0;
          right: 0;
          height: 160px;

          .title {
            height: 27px;
            opacity: 1;
            /** 文本1 */
            font-size: 20px;
            font-weight: 400;
            letter-spacing: 0px;
            line-height: 27px;
            color: rgba(56, 56, 56, 1);
            text-align: left;
            vertical-align: top;
          }

          .time {
            margin-top: 8px;
            height: 20px;
            opacity: 1;
            /** 文本1 */
            font-size: 13px;
            font-weight: 400;
            letter-spacing: 0px;
            line-height: 20px;
            color: rgba(153, 153, 153, 1);
            text-align: left;
            vertical-align: top;
          }

          .detail {
            margin-top: 18px;
            width: 100%;
            height: 42px;
            opacity: 1;
            /** 文本1 */
            font-size: 14px;
            font-weight: 400;
            letter-spacing: 0px;
            line-height: 20px;
            color: rgba(153, 153, 153, 1);
            text-align: justify;
            vertical-align: top;
            @include ellipsis($line: 2);
          }
        }
      }
    }
  }
</style>

